<?php
/**
 * @link http://www.tpframe.com/
 * @copyright Copyright (c) 2017 TPFrame Software LLC
 * @author 510974211@qq.com
 */
namespace app\backend\controller;
use app\common\controller\AdminBase;
use \tpfcore\Core;
class UserBankCard extends AdminBase
{
    public function index(){
        if(IS_GET) return $this->fetch();
        if(IS_POST || IS_AJAX){
            $this->jump([0,"success",Core::loadAddonModel($this->name,"common")->getUserBankCard([
                "field"=>"__USER__.nickname,__BANK_LIST__.name,__BANK_LIST__.logo,__BANK_LIST__.type,__USER_BANK_CARD__.id,__USER_BANK_CARD__.real_name,__USER_BANK_CARD__.card_number,__USER_BANK_CARD__.phone,__USER_BANK_CARD__.add_time",
                "join"=>[
                    "join"=>['__BANK_LIST__','__USER__'],
                    "condition"=>['__BANK_LIST__.id = __USER_BANK_CARD__.bank_id','__USER_BANK_CARD__.user_id = __USER__.id'],
                    "type"=>['left','left']
                ],
                'paginate'=>['rows' => 30],
                "order"=>"__USER_BANK_CARD__.add_time desc"
            ])]);
        }
    }

    public function del(){
        if(IS_POST || IS_AJAX){
            $this->jump(Core::loadAddonModel($this->name,'common')->delUserBankCard(['id'=>$this->param['id']]));
        }
    }
}
?>